package com.org.controller.pc;

import com.org.entity.BackupCollectItems;
import com.org.entity.BackupSearchItems;
import com.org.entity.CollectItems;
import com.org.entity.SearchItems;
import com.org.message.BaseMessage;
import com.org.result.Result;
import com.org.service.BackupService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * 备份控制器
 */
@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/pc/backup")
public class BackupController {

    private final BackupService backupService;

    /**
     * 新增失物招领信息备份
     */
    @PostMapping("/addCollectItems")
    public Result<String> addCollectItems(@RequestBody BackupCollectItems backupCollectItems) {
        backupService.addCollectItems(backupCollectItems);
        return Result.success(BaseMessage.INSERT_SUCCESS);
    }

    /**
     * 新增寻物启事信息备份
     */
    @PostMapping("/addSearchItems")
    public Result<String> addSearchItems(@RequestBody BackupSearchItems backupSearchItems) {
        backupService.addSearchItems(backupSearchItems);
        return Result.success(BaseMessage.INSERT_SUCCESS);
    }

    /**
     * 删除所有备份信息
     */
    @DeleteMapping("/deleteAll")
    public Result<String> deleteAll(LocalDateTime time) {
        backupService.deleteAll(time);
        return Result.success(BaseMessage.DELETE_SUCCESS);
    }

}
